package ch.janotta.slawo.da.algirithm.lifecycle;

import ch.janotta.slawo.da.Ability;
import ch.janotta.slawo.da.Background;
import ch.janotta.slawo.da.CharacterClass;
import ch.janotta.slawo.da.Entity;
import ch.janotta.slawo.da.tables.AttributeValuesTable;
import ch.janotta.slawo.utilities.Dice;

public class AbilityBasedEntityLifecycleHandlingAlgorithm extends AbstractEntityLifecycleHandlingAlgorithm {
  @Override
  protected void generateInitialAbilities(Entity entity) {
    entity.setCommunication(AttributeValuesTable.getRandomAttributeValue());
    entity.setConstitution(AttributeValuesTable.getRandomAttributeValue());
    entity.setCunning(AttributeValuesTable.getRandomAttributeValue());
    entity.setDexterity(AttributeValuesTable.getRandomAttributeValue());
    entity.setMagic(AttributeValuesTable.getRandomAttributeValue());
    entity.setPerception(AttributeValuesTable.getRandomAttributeValue());
    entity.setStrength(AttributeValuesTable.getRandomAttributeValue());
    entity.setWillpower(AttributeValuesTable.getRandomAttributeValue());
  }

  @Override
  protected void generateBackground(Entity entity) {
    Ability ability = entity.getMaximumStartingAbility();
    entity.setBackground(Background.getBestRandomInstanceForAbility(ability));
  }

  @Override
  protected void generateCharacterClass(Entity entity) {
    CharacterClass[] possibleClasses = CharacterClass.bestClassesForAbilities(entity);
    int lastPossibleClass = possibleClasses.length;
    int randomClassIndex = Dice.getRandomNumber(lastPossibleClass) - 1;
    entity.setCharacterClass(possibleClasses[randomClassIndex]);
  }

  @Override
  protected void performAdditionalLevelUpOperations(Entity entity) {
    // TODO Auto-generated method stub
    
  }
}
